xml 在Miva Feed中获取variant_id

variant_id
<mvt:do name="l.productvariantpart_count" file="g.Module_Library_DB" value="ProductVariantPartList_Load_Part(l.settings:record:variant:id, l.settings:productvariantparts)" />
&mvt:record:variant:code;: &mvt:record:variant:id;<br>
<mvt:foreach iterator="part" array="productvariantparts">
	Part ID: &mvt:part:part_id;<br>
	Master Product ID: &mvt:part:product_id; <br>
	Quantity: &mvt:part:quantity; <br>
	Variant Id: &mvt:part:variant_id;<br>
</mvt:foreach>

xml 属性Util

PropertiesUtil.java
import java.io.*;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * @author Hamid
 */
public class PropertiesUtil {
    
    private static final String PROPERTIES_EXTENSION = ".properties";

    private static final String DEFAULT_CONFIG_FILE_NAME = "config";

    private File file;
    
    private final Properties properties;

    public PropertiesUtil(File file) {
        this.file = file;
        properties = new Properties();
    }

    /**
     * write to property file
     * @param propertyName property filename
     * @param propertyValue string value to write
     * @throws IOException cannot find file
     */
    public void write(String propertyName, String propertyValue) throws IOException {
        try (OutputStream output = new FileOutputStream(file)) {
            properties.setProperty(propertyName, propertyValue);
            properties.store(output, null);
        }
    }

    /**
     * read values by property filename
     * @param propertyName property filename
     * @return plain text
     * @throws IOException cannot find file
     */
    public String read(String propertyName) throws IOException{
        try(InputStream inputStream = new FileInputStream(file)){
            properties.load(inputStream);
            return properties.getProperty(propertyName);
        }
    }

    /**
     * reads all existing properties in config file
     * @return map with values of property file
     * @throws IOException cannot find file
     */
    public Map<String, String> readAll() throws IOException{
        try(InputStream inputStream = new FileInputStream(file)){
            Map<String,String> propertyNames = new HashMap<>();
            properties.load(inputStream);
            Enumeration<?> enumeration = properties.propertyNames();
            while(enumeration.hasMoreElements()){
                String element = (String) enumeration.nextElement();
                propertyNames.put(element,properties.getProperty(element));
            }
            return propertyNames;
        }
    }

    
}
PropertiesUtilTest.java
import org.junit.After;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import static org.junit.Assert.*;

public class PropertiesUtilTest extends BaseTest {

    private static final String PROPERTY_NAME = "config";
    private static final File propertyFile = new File(PROPERTY_NAME + ".properties");


    @After
    public void tearDown() {
        if (propertyFile.exists()){
            propertyFile.delete();
        }
    }

    @Test
    public void testWriteAndRead(){
        try {
            PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);
            propertiesUtil.write("key","value");
            assertEquals("value",propertiesUtil.read("key"));
        } catch (IOException e) {
            fail(e.getMessage());
        }
    }

    @Test
    public void testOverwrite(){
        try {
            PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);
            propertiesUtil.write("key","value");
            propertiesUtil.write("key","overwritten value");

            // make sure it didn't create any duplicate
            assertEquals(1,propertiesUtil.readAll().size());

            // current value equals over written value
            assertEquals("overwritten value",propertiesUtil.read("key"));

        } catch (IOException e) {
            fail(e.getMessage());
        }
    }

    @Test(expected = NullPointerException.class)
    public void testWriteNullPropertyName(){
        try {
            PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);
            propertiesUtil.write(null,"value");
            fail();
        } catch (IOException e) {
            fail(e.getMessage());
        }
    }

    @Test(expected = NullPointerException.class)
    public void testWriteNullPropertyValue(){
        try {
            PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);
            propertiesUtil.write("key",null);
            fail();
        } catch (IOException e) {
            fail(e.getMessage());
        }
    }

    @Test
    public void testWriteNotExistFile(){
        try {
            PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);

            // because properties will create after first write
            propertiesUtil.write("firstKey","firstValue");

            if(new File(PROPERTY_NAME+".properties").delete()){

                // propertiesUtil in this case needs to be reinitialized
                // otherwise it has the properties config and create the file
                // with both value and without any issue
                propertiesUtil = new PropertiesUtil(propertyFile);

                propertiesUtil.write("secondKey","secondValue");

                assertNull(propertiesUtil.read("firstKey"));
                assertEquals("secondValue",propertiesUtil.read("secondKey"));
            }else{
                fail("scenario gone wrong. file didn't removed.");
            }
        } catch (IOException e) {
            fail(e.getMessage());
        }
    }

    @Test
    public void testReadNull(){
        try {
            PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);

            // file does not exist
            propertiesUtil.read(null);
            fail();
        } catch (IOException e) {
            assertTrue(true);
        }
    }

    @Test
    public void testReadNotExistingPropertyKey(){
        try {
            PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);

            // write to create property file
            propertiesUtil.write("firstKey","secondKey");

            assertNull(propertiesUtil.read("notExistingKey"));
        } catch (IOException e) {
            fail(e.getMessage());
        }
    }

    @Test
    public void testCreatePropertiesWithNull(){
        new PropertiesUtil(null);
    }

    @Test
    public void testReadAll(){
        PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);
        try {
            propertiesUtil.write("firstKey","firstValue");
            propertiesUtil.write("secondKey","secondValue");
            propertiesUtil.write("thirdKey","thirdValue");

            Map<String,String> config = propertiesUtil.readAll();
            assertEquals("firstValue",config.get("firstKey"));
            assertEquals("secondValue",config.get("secondKey"));
            assertEquals("thirdValue",config.get("thirdKey"));

        } catch (IOException e) {
            fail(e.getMessage());
        }
    }

    @Test
    public void testReadAllEmptyFile(){
        PropertiesUtil propertiesUtil = new PropertiesUtil(propertyFile);
        try {
            // file not exist
            Map<String,String> config = propertiesUtil.readAll();
            fail();
        } catch (IOException e) {
            assertTrue(true);
        }
    }
}
BaseTest.java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class BaseTest {
  
    protected void writeFile(File file,String content) throws IOException {
        FileOutputStream outputStream = new FileOutputStream(file);
        outputStream.write(content.getBytes());
        outputStream.close();
    }

}
pom.xml
        <!-- junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

xml 活动主要

activity_main.xml
You can replace Constraint Layout with Linear Layout.

<!-- In Linear Layout opening tag. -->

android:background="@color/background"
android:orientation="vertical"
android:gravity="center"

activity_main_2.xml
<!-- Inside Linear Layout tag. -->

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher_foreground"
        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/white"            // Needs Defn in Strings.xml
        android:textColor="@android:color/white"    // Direct Access from predefined colors
        android:padding="8dp"
        android:textSize="27sp"
        android:id="@+id/answers"
        android:text="Test Question"
        />
        
    <Button
            android:id="@+id/Option2"
            android:text="@string/rick_sanchez"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="65dp"
            android:layout_marginTop="20dp"
            />
            

xml Android Manifest

androidmanifest.xml
<uses-permission android:name = ""> 

xml QueryDsl使用相关

QueryDsl.java
package com.markor.activities.activitymanagement.bean;

import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.persistence.EntityManager;

/**
 * @author sunnannan
 * @Title: JpaDslFactoryBean
 * @ProjectName mk-marketing-service
 * @Description: JPAQueryFactory  QueryDsl 用来实例化dsl查询工厂类 查询用的bean
 * *  使用样例;
 * *      1.@Autowired JPAQueryFactory jPAQueryFactory;
 * *      2.jpaQueryFactory.selectFrom(QUserEntity.userEntity))
 * *          .where(QUserEntity.userEntity.account.eq(userAccount))
 * *          .fetchOne();
 * @date 2018/10/1014:52
 */
@Configuration
public class JpaDslFactoryBean {

    @Autowired
    private EntityManager entityManager;

    @Bean
    public JPAQueryFactory jpaQuery() {
        return new JPAQueryFactory(entityManager);
    }

}
pom.xml
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>4.1.4</version>
            <scope>provided</scope>
        </dependency>
        <plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>apt-maven-plugin</artifactId>
                <version>1.1.3</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/generated-sources/java</outputDirectory>
                            <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

xml UPS i-parcel Preprovide

i-parcel_PreProvide
<Module code="iparcel" feature="shipping">
	<Settings>
		<APIKey>...</APIKey>
		<Currency>USD</Currency>
		<CartHandoff>Yes|No</CartHandoff>
		
		<EnabledServices>
			<Service servicenumber="115" />
			<Service servicenumber="112" />
			<Service servicenumber="119" />
			<Service servicenumber="207" />
			<Service servicenumber="208" />
			<Service servicenumber="254" />
			<Service servicenumber="265" />
		</EnabledServices>
	</Settings>
</Module>

xml 测试

system.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
	<tabs>
		<smsnotification translate="label" module="smsnotification">
			<label>Sms Notification</label>
			<sort_order>1</sort_order>
		</smsnotification>
	</tabs>
	<sections>
		<smsnotification translate="label" module="smsnotification">
			<label>Setting</label>
			<tab>smsnotification</tab>
			<frontend_type>text</frontend_type>
			<sort_order>0</sort_order>
			<show_in_default>1</show_in_default>
			<show_in_website>1</show_in_website>
			<show_in_store>1</show_in_store>
			<groups>
				<smsnotification translate="label">
					<label>General</label>
					<frontend_type>text</frontend_type>
					<sort_order>0</sort_order>
					<show_in_default>1</show_in_default>
					<show_in_website>1</show_in_website>
					<show_in_store>1</show_in_store>
					<fields>
						<smsnotification translate="label">
							<label>Enable/Disable</label>
							<frontend_type>select</frontend_type>
							<source_model>adminhtml/system_config_source_enabledisable</source_model>
							<sort_order>0</sort_order>
							<show_in_default>1</show_in_default>
							<show_in_website>1</show_in_website>
							<show_in_store>1</show_in_store>
						</smsnotification>
					</fields>
				</smsnotification>
			</groups>
			<groups>
				<smsconfig translate="label">
					<label>Configuration</label>
					<frontend_type>text</frontend_type>
					<sort_order>0</sort_order>
					<show_in_default>1</show_in_default>
					<show_in_website>1</show_in_website>
					<show_in_store>1</show_in_store>
					<fields>
						<smsservices translate="label">
							<label>Sms Services</label>
							<frontend_type>select</frontend_type>
							<source_model>smsnotification/smsmodel</source_model>
							<sort_order>0</sort_order>
							<show_in_default>1</show_in_default>
							<show_in_website>1</show_in_website>
							<show_in_store>1</show_in_store>
						</smsservices>
					</fields>
					<fields>
						<accountsid translate="label">
							<label>Account SID</label>
							<frontend_type>text</frontend_type>
							<sort_order>0</sort_order>
							<show_in_default>1</show_in_default>
							<show_in_website>1</show_in_website>
							<show_in_store>1</show_in_store>
							<depends>
								<smsservices>twilio</smsservices>
							</depends>
						</accountsid>
					</fields>
					<fields>
						<authtoken translate="label">
							<label>Auth Token</label>
							<frontend_type>text</frontend_type>
							<sort_order>2</sort_order>
							<show_in_default>1</show_in_default>
							<show_in_website>1</show_in_website>
							<show_in_store>1</show_in_store>
							<depends>
								<smsservices>twilio</smsservices>
							</depends>
						</authtoken>
					</fields>
					<fields>
						<apiendpoint translate="label">
							<label>URL</label>
							<frontend_type>text</frontend_type>
							<sort_order>4</sort_order>
							<show_in_default>1</show_in_default>
							<show_in_website>1</show_in_website>
							<show_in_store>1</show_in_store>
							<depends>
								<smsservices>twilio</smsservices>
							</depends>
							<comment><![CDATA[<a href='https://www.twilio.com/docs/sms/api' target="_blank">twilio.com</a>. Twilio]]></comment>
						</apiendpoint>
					</fields>
				</smsconfig>
			</groups>
			<groups>
				<orderevents translate="label">
					<label>Order Event Messages</label>
					<frontend_type>text</frontend_type>
					<sort_order>0</sort_order>
					<show_in_default>1</show_in_default>
					<show_in_website>1</show_in_website>
					<show_in_store>1</show_in_store>
					<fields>
						<newordersms translate="label">
							<label>New Order Message</label>
							<frontend_type>textarea</frontend_type>
							<sort_order>0</sort_order>
							<show_in_default>1</show_in_default>
							<show_in_website>1</show_in_website>
							<show_in_store>1</show_in_store>
							<comment><![CDATA[<p> Variable parameters <b> :  {{customer_name}},{{order_amt}},{{order_id}} </b> </p>]]></comment>
						</newordersms>
					</fields>
					<fields>
						<shipmentsms translate="label">
							<label>Shipment Message</label>
							<frontend_type>textarea</frontend_type>
							<sort_order>2</sort_order>
							<show_in_default>1</show_in_default>
							<show_in_website>1</show_in_website>
							<show_in_store>1</show_in_store>
							<comment><![CDATA[<p> Variable parameters <b> :  {{customer_name}},{{tracking_number}} </b> </p>]]></comment>
						</shipmentsms>
					</fields>
				</orderevents>
			</groups>
			<groups>
				<customersms translate="label">
					<label>Customer Event Messages</label>
					<frontend_type>text</frontend_type>
					<sort_order>0</sort_order>
					<show_in_default>1</show_in_default>
					<show_in_website>1</show_in_website>
					<show_in_store>1</show_in_store>
					<fields>
						<customerregister translate="label">
							<label>Register Message</label>
							<frontend_type>textarea</frontend_type>
							<sort_order>4</sort_order>
							<show_in_default>1</show_in_default>
							<show_in_website>1</show_in_website>
							<show_in_store>1</show_in_store>
							<comment><![CDATA[<p> Variable parameters <b> :  {{customer_name}}</b> </p>]]></comment>
						</customerregister>
					</fields>
				</customersms>
			</groups>
		</smsnotification>
	</sections>
</config>

xml ConfiguraçãoPHP单元

phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
        bootstrap="./tests/Bootstrap.php"
        colors="true"
        convertErrorsToExceptions="true"
        convertNoticesToExceptions="true"
        convertWarningsToExceptions="true"
        verbose="true"
        syntaxCheck="true">
    <logging>
        <log type="testdox-text" target="./tests/testdox.txt"/>
    </logging>
    <php>
        <server name="HTTP_USER_AGENT" value="PHP Unit Test"/>
    </php>
    <testsuites>
        <testsuite name="TestUnit">
            <directory>./tests</directory>
        </testsuite>
    </testsuites>
</phpunit>

xml 资源字典在一个单独的文件中

[LINK](https://social.msdn.microsoft.com/Forums/vstudio/en-US/e37b528e-f797-4b91-84fe-03ddd7fb57c1/custom-style-in-an-external-file?forum=wpf)

AddResourceDictionary
<StackPanel.Resources>
  <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="/Styles/MyFile.xaml" /> <!--Folder "Styles" in the project-->>
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</StackPanel.Resources>
UsingStyleFromResourceDictionary
<TextBlock Text="{Binding Path=Name}" Style="{StaticResource MyStyleName}" />
SeparateResourceDictionary
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:CaliburnMicroTest.Styles">
    <Style x:Key="MyStyle" TargetType="TextBlock">
        <Setter Property="Margin" Value="0,0,0,20" />
    </Style>
</ResourceDictionary>

xml Laravel测试

Faker文档:https://github.com/fzaninotto/Faker

terminal.md
## Run the following command to run all tests:
`vendor/bin/phpunit`   

Create an Alias (optional)  
`alias test="vendor/bin/phpunit"`  
`alias pf="vendor/bin/phpunit --filter"`

Test a single file (after creating alias):  
`test tests/Feature/ExampleTest.php`

Test a specific method (after creating alias):  
`pf a_user_can_create_a_project`  
`pf ProjectsTest`  

## Creating a Test
1. Create a test in the Feature directory  
`php artisan make:test TeamsTest`

2. Create a test in the Unit directory  
`php artisan make:test TeamsTest --unit`
TeamsTest.php
<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class TeamsTest extends TestCase
{
    // * Refreshes the database if there has been any change in the database (prevents multiple duplicate records, etc)
    // * RefreshDatabase also runs migrations for you
    use RefreshDatabase;

    /**
     * A basic feature test example.
     *
     * @return void
     */
    // public function testExample()
    // {
    //     $response = $this->get('/');

    //     $response->assertStatus(200);
    // }

    /** @test */
    public function a_user_can_create_a_team() {

        $this->withoutExceptionHandling(); // * This can be something you temporarily add as you're testing

        // Given I am a user who is logged in
        $this->actingAs(factory('App\User')->create());

        // When they hit the endpoint /teams to create a new team, while passing the necessary data
        $attributes = ['name' => 'Acme'];

        $this->post('/teams', $attributes);

        // Then there should be a new team in the database
        $this->assertDatabaseHas('teams', $attributes);

        // * Note: The route(s) and database do not exist yet. 
        // * We are writing the test before the code has been written. 
        // * And this is called Basic Test-Driven Development.

    }

    /** @test */
    public function guests_may_not_create_teams() {

        // $this->withoutExceptionHandling();

        $this->post('/teams')->assertRedirect('/login');

    }

}
web.php
<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

// * Part of the Testing Course
Route::post('/teams', function() {

    $attributes = request()->validate(['name' => 'required']);
    $attributes['user_id'] = auth()->id();

    App\Team::create($attributes);

    return redirect('/');

});
migration_create_teams_table.php
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTeamsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('teams', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('user_id');
            $table->string('name');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('teams');
    }
}
Team.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Team extends Model
{
    protected $guarded = [];
}
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
  <!-- // ... -->
  <php>
      <!-- // ... -->
      <!-- Add the following lines to avoid testing on mysql production database, and instead run tests on sqlite database -->
      <server name="DB_CONNECTION" value="sqlite"/>
      <server name="DB_DATABASE" value=":memory:"/>
  </php>
</phpunit>